#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long L;
const int MAXN = 2e5 + 1;
int a[MAXN];
bool b[MAXN];
bool cmp(int x,int y){return x > y;}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T,n;
    cin >> T;
    while(T--){
        cin >> n;
        L s = 0;
        for(int i = 1;i <= n;i++){
            cin >> a[i];
            s += a[i];
            b[a[i]] = 1;
        }
        for(int i = 1;i <= MAXN;i++){
            if(b[i]) s -= i;
        }
        cout << s << endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
